package com.itheima.requ;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

@WebServlet("/dem04")
public class Servlet04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String s = "这是一个静态响应头，控制缓存时间";
        resp.setContentType("text/html;charset=UTF-8");
        resp.setDateHeader("expires", System.currentTimeMillis() + 1 * 60 * 60 * 1000);
//        resp.getWriter().write(s);
//        System.out.println("ss");
        resp.getOutputStream().write(s.getBytes("utf-8"));
        System.out.println("ss");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
